package regexInput;
import java.io.Serializable;
import java.util.ArrayList;

public class DSList implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -6266382676963181388L;
	private ArrayList<Node> charClass;
	private ArrayList<Node> idenitfiers;
	
	public DSList(){
		charClass = new ArrayList<Node>();
		idenitfiers = new ArrayList<Node>();
	}
	
	public void addClass(Node charSpecs){
		charClass.add(charSpecs);
	}
	
	public void addIden(Node Iden){
		idenitfiers.add(Iden);
	}
	
	public char[] getSpecs(String name){
		for(int i = 0; i < charClass.size(); i++){
			if(charClass.get(i).getName().equals(name)){
				return charClass.get(i).getList(); 
			}
		}
		return new char[0];
	}
	
	public String[] getCharClass(){
		String[] temp = new String[charClass.size()];
		for(int i = 0; i < charClass.size(); i++){
			temp[i] = charClass.get(i).getName();
		}
		return temp;
	}
	
	public String[] getValidTokenNames(){
		String[] temp = new String[idenitfiers.size()];
		for(int i = 0; i < idenitfiers.size(); i++){
			temp[i] = idenitfiers.get(i).getName();
		}
		return temp;
	}
	
	public ArrayList<Node> getCharNodes(){
		return charClass;
	}
	
	public String[] getValidREGEX(){
		String[] temp = new String[idenitfiers.size()];
		for(int i = 0; i < idenitfiers.size(); i++){
			temp[i] = idenitfiers.get(i).getTheRegExp();
		}
		return temp;
	}
	
	public String toString(){
		String str = "~~Character Classes~~\n";
		for(Node node : charClass){
			str += node.toString(1);
		}
		str += "~~Token Definitions~~\n";
		for(Node node : idenitfiers){
			str += node.toString(2);
		}
		return str;
	}
}
